Scalar-valued Functions [dbo].[fn_asi_convert_foreign_chars]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@incharvarchar1
Permissions
TypeActionOwning Principal
GrantExecuteIMIS
SQL Script

/****** Object:  UserDefinedFunction dbo.fn_asi_convert_foreign_chars  ******/

CREATE function dbo.fn_asi_convert_foreign_chars(@inchar varchar(1))
returns varchar(1)
as
begin
    declare @outchar varchar(1)

    if ascii(@inchar)<128
    begin
        -- not in extended ascii character set, just return it
        return @inchar
    end

    select @outchar =
    case ascii(@inchar)
        when ascii('À') then 'A'
        when ascii('Á') then 'A'
        when ascii('Â') then 'A'
        when ascii('Ã') then 'A'
        when ascii('Ä') then 'A'
        when ascii('Å') then 'A'
        when ascii('Æ') then 'A'
        when ascii('Ç') then 'C'
        when ascii('È') then 'E'
        when ascii('É') then 'E'
        when ascii('Ê') then 'E'
        when ascii('Ë') then 'E'
        when ascii('Ì') then 'I'
        when ascii('Í') then 'I'
        when ascii('Î') then 'I'
        when ascii('Ï') then 'I'
        when ascii('Ð') then 'D'
        when ascii('Ñ') then 'N'
        when ascii('Ò') then 'O'
        when ascii('Ó') then 'O'
        when ascii('Ô') then 'O'
        when ascii('Õ') then 'O'
        when ascii('Ö') then 'O'
        when ascii('×') then 'x'
        when ascii('Ø') then 'O'
        when ascii('Ù') then 'U'
        when ascii('Ú') then 'U'
        when ascii('Û') then 'U'
        when ascii('Ü') then 'U'
        when ascii('Ý') then 'Y'
        when ascii('Þ') then 'P'
        when ascii('ß') then 's'
        when ascii('à') then 'a'
        when ascii('á') then 'a'
        when ascii('â') then 'a'
        when ascii('ã') then 'a'
        when ascii('ä') then 'a'
        when ascii('å') then 'a'
        when ascii('æ') then 'a'
        when ascii('ç') then 'c'
        when ascii('è') then 'e'
        when ascii('é') then 'e'
        when ascii('ê') then 'e'
        when ascii('ë') then 'e'
        when ascii('ì') then 'i'
        when ascii('í') then 'i'
        when ascii('î') then 'i'
        when ascii('ï') then 'i'
        when ascii('ð') then 'o'
        when ascii('ñ') then 'n'
        when ascii('ò') then 'o'
        when ascii('ó') then 'o'
        when ascii('ô') then 'o'
        when ascii('õ') then 'o'
        when ascii('ö') then 'o'
        when ascii('ø') then 'o'
        when ascii('ù') then 'u'
        when ascii('ú') then 'u'
        when ascii('û') then 'u'
        when ascii('ü') then 'u'
        when ascii('ý') then 'y'
        when ascii('þ') then 'b'
        when ascii('ÿ') then 'y'
        else ''
    end

    return @outchar

end


GO
GRANT EXECUTE ON  [dbo].[fn_asi_convert_foreign_chars] TO [IMIS]
GO
Uses
Used By